<template></template>
<script setup>
import {ElLoading, ElMessage, ElMessageBox} from 'element-plus'
import {usePageSpy} from "~/store";

const $page_spy = usePageSpy()
window.$message = () => {
  ElMessage.closeAll()
  return ElMessage
}
window.$box = ElMessageBox
let loading = null
window.$loading = () => {
  return {
    open: () => {
      loading = ElLoading.service({
        lock: true,
        text: '加载中...',
      })
    },
    close: () => {
      loading.close()
    },
  }
}

if (!!$page_spy.value) {
  const script = document.createElement('script');
  script.src = $page_spy.value + '/page-spy/index.min.js';
  script.crossOrigin = 'anonymous';
  script.onload = function () {
    window.$pageSpy = new PageSpy();
  };
  document.head.appendChild(script);
}
</script>
